#include <iostream>
#include <vector>
using namespace std;

int max_value_dp(vector<vector<int>> &val, int F, int V, vector<vector<int>> &bk)
{
        vector<vector<int>> dp(F + 1, vector<int>(V + 1, 0));
        for(int i = 1; i <= F; i++){
                for(int j = i; j <= V; j++){
                        dp[i][j] = INT32_MIN;
                        bk[i][j] = -1;
                        for(int k = i; k <= j; k++){
                                int worth = dp[i - 1][k - 1] + val[i][k];
                                if(worth >= dp[i][j]){
                                        dp[i][j] = worth;
                                        bk[i][j] = k;
                                }
                                //dp[i][j] = max(dp[i][j], dp[i - 1][k - 1] + val[i][k]);
                        }
                }
        }
        return dp.back().back();
}

int print_ans(vector<vector<int>> &bk, int F, int V)
{
        if(F == 1){
                cout<<bk[F][V]<<" ";
                return 0;
        }
        if(bk[F][V] == -1){
                print_ans(bk, F - 1, V);
        }else{
                print_ans(bk, F - 1, bk[F][V] - 1);
        }
        cout<<bk[F][V]<<" ";
        return 0;
}

int main()
{
        int F, V;
        cin>>F>>V;
        vector<vector<int>> value(F + 1, vector<int>(V + 1, 0)), back(value);
        for(int i = 1; i <= F; i++){
                for(int j = 1; j <= V; j++){
                        cin>>value[i][j];
                }
        }
        cout<<max_value_dp(value, F, V, back)<<endl;
        print_ans(back, F, V);
        cout<<endl;
        return 0;
}